import userUtils from "../../utils/userUtils"
import APIClient from "../../network/index"
const userStore = {
    state: {
        isLogin:userUtils.isLogin(),
        mobile:''
      },
      mutations: {
          setToken(state,goods){

          },
          get_user_info(state,goods){
            state.mobile = goods
          }
      },
      actions: {
        REGISTER(context,obj){
            APIClient.get_user_token({
                params:{
                    mobile:obj.mobile,
                    pwd:obj.pwd
                }
            }).then((res)=>{
                userUtils.setToken(res.data.data.token)
                userUtils.isLogin()
                context.commit("setToken",res.data.data.token)
            })
        },
        get_user_info(context){
            APIClient.get_user_info({
                params:{
                    token:userUtils.getToken()
                }
            }).then((res)=>{
                console.log(res.data.data)
                context.commit("get_user_info",res.data.data.base.mobile)
            })
        }
      }
}
export default userStore